| Total Complexity | 1 |
| Total Lines | 19 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import { Inject } from '@nestjs/common'; |
||
| 5 | |||
| 6 | export class DoesLeaveExistForPeriod { |
||
| 7 | constructor( |
||
| 8 | @Inject('ILeaveRepository') |
||
| 9 | private readonly leaveRepository: ILeaveRepository |
||
| 10 | ) {} |
||
| 11 | |||
| 12 | public async isSatisfiedBy( |
||
| 13 | user: User, |
||
| 14 | startDate: string, |
||
| 15 | endDate: string |
||
| 16 | ): Promise<boolean> { |
||
| 17 | const leaves = await this.leaveRepository.countLeavesByUserAndPeriod( |
||
| 18 | user, |
||
| 19 | startDate, |
||
| 20 | endDate |
||
| 21 | ); |
||
| 22 | |||
| 23 | return leaves > 0; |
||
| 24 | } |
||
| 26 |